package com.pig4cloud.pigx.wxApi.mapper;

import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
import com.pig4cloud.pigx.wxApi.entity.SysUserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 用户信息表 Mapper 接口
 * </p>
 */
@Mapper
public interface UserInfoMapper extends PigxBaseMapper<SysUserInfo> {

	@Update("update user_info set password= #{pwd} where phone=#{mobile}")
	int updatePwdByMobile(String mobile, String pwd);

	@Update("update user_info set password= #{pwd} where user_id=#{userId}")
	int updatePwdByUserId(Long userId, String pwd);

	@Update(" update user_info set fans = fans + 1,collect=collect+1,attention=attention+1 where user_id = #{id}")
	int addCollect(Long id);

	@Update(" update user_info set fans = fans - 1,collect=collect-1,attention=attention-1 where user_id = #{id}")
	int reduceCollect(Long id);

	@Update(" update user_info set view = view + 1 where user_id = #{id}")
	int addViews(Long id);

	@Update("update user_info set phone= #{newMobile} where phone=#{oldMobile}")
	int updateMobileByMobile(String oldMobile, String newMobile);

	@Select("select user_id from user_info where phone = #{username} or email = #{username} or name= #{username}")
	Long findUserByPhoneOrNameOrEmail(@Param("username") String username);
}
